<template>
  <div>
    <div class="main" v-if="isShow">
       <eagle-input
        class="input_text"
        readonly
        label="年度"
        v-model="form.Year"
        required
      >
      </eagle-input>
      <eagle-input
        class="input_text"
        readonly
        label="演练类型"
        v-model="form.DrillTypeName"
        required
      >
      </eagle-input>
      <eagle-input
        class="input_text"
        readonly
        label="演练名称"
        v-model="form.DrillName"
        required
      >
      </eagle-input>
      <eagle-input
        class="input_text"
        readonly
        label="对应预案文件"
        v-model="form.FileName"
        required
      >
      </eagle-input>
      <eagle-input
        class="input_text"
        readonly
        label="预案类型"
        v-model="form.PlanType"
        required
      >
      </eagle-input>
      <eagle-input
        label="演练开始日期"
        class="input_text"
        required
        :value="getDate(form.DrillStartDate)"
        readonly
      ></eagle-input>
      <eagle-input
        label="演练结束日期"
        class="input_text"
        :value="getDate(form.DrillEndDate)"
        readonly
        required
      ></eagle-input>
      <eagle-input
        class="input_text"
        readonly
        label="组织部门"
        v-model="form.OriginatingDeptName"
        required
      >
      </eagle-input>
      <eagle-input
        readonly
        label="参与部门"
        v-model="form.PartDeptName"
        required
        autosize
        rows="1"
        type="textarea"
      >
      </eagle-input>
      <eagle-input
        class="input_text"
        readonly
        autosize
        label="演练范围"
        v-model="form.DrillRange"
        required
        type="textarea"
      >
      </eagle-input>
      <eagle-input
        class="input_text"
        readonly
        autosize
        required
        label="演练目标"
        v-model="form.DrillTarget"
        type="textarea"
      >
      </eagle-input>
    </div>
    <div class="main" v-if="isEdit">
      <eagle-input
        class="input_text"
        readonly
        label="应急演练人员"
        v-model="form.DrillChnName"
        required
      >
      </eagle-input>
      <eagle-input
        class="input_text"
        readonly
        label="应急演练地点"
        v-model="form.DrillAddress"
        required
      >
      </eagle-input>
      <eagle-input
        label="应急演练资金"
        class="input_text"
        required
        type="number"
        :value="form.DrillMoney"
        readonly
      ></eagle-input>
      <eagle-file-view
        :attachs="form.PlanAttachs"
        required
        :labelName="'演练方案'"
      />
      <eagle-file-view
        :attachs="form.DrillAttachs"
        required
        :labelName="'演练记录'"
      />
      <eagle-file-view
        :attachs="form.ScriptAttachs"
        required
        :labelName="'演练脚本'"
      />
      <eagle-input
        class="input_text"
        readonly
        label="备注"
        autosize
        v-model="form.Remarks"
        type="textarea"
      >
      </eagle-input>
    </div>
  </div>
</template>

<script>
import { getDate } from "@/utils/getDate";
import { keepTwoDecimalFull } from "@/utils/common.js";

export default {
  data() {
    return {
      isEdit: this.$route.query.isEdit,
      isShow: this.$route.query.isShow,
      filter: {
        id: this.$route.query.id,
      },
      form: {},
    };
  },
  created() {
    if (this.$route.query.id != null) {
      this.getDetail();
    }
  },
  methods: {
    getDate(value) {
      return getDate(value);
    },
    getDetail() {
      let _this = this;
      _this.$axios
      .get("/PlanSimpleDrillPlan/GetDetail",{params:_this.filter})
      .then((res) => {
        // _this.form.DrillMoney = "^[0-9]+(.[0-9]{1,2})?$";
        // _this.form.DrillMoney = Math.round(this.form.DrillMoney * 100) / 100;
        _this.form.DrillMoney = keepTwoDecimalFull(_this.form.DrillMoney);
        _this.form = res.data;
      });
    },
  },
};
</script>

<style lang="less">
.wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.block {
  width: 120px;
  height: 120px;
  background-color: #fff;
}
</style>
<style lang="less" scoped>
.space-between {
  justify-content: space-between;
}
</style>
